﻿
Namespace PL.MESSDK
    Public Class ItemMasterSpecification_PL
        Inherits PLBase

        Public Sub New()
            MyBase.New()
        End Sub

        Public Sub New(ByVal queryName As String)
            MyBase.New(queryName)
        End Sub

        Public Overrides Function Delete() As Boolean
            'Throw New NotImplementedException("Delete To Come...")
            Return False
        End Function

        Public Overrides Function Validate() As Boolean
            'Throw New NotImplementedException("Validate To Come...")
            Return True
        End Function
        Public Shared Function GetIMSById(ByVal itemMasterSpecID As Guid) As DataRow
            Dim dr As DataRow = MetaQuery.GetDataById("ItemMasterSpecification", itemMasterSpecID)
            Return dr
        End Function

        Public Shared Function GetCurrentIMS(ByVal prdID As Guid, ByVal siteID As Guid, ByVal specID As Guid) As DataRow
            Dim aRow As DataRow = Nothing
            Dim reader As SqlDataReader = Nothing
            Dim dt As DataTable = New DataTable()
            Using sqlcmd As SqlCommand = MetaQuery.GetSPCmdByMetaName("GetCurrentIMSpecification")
                sqlcmd.Parameters("@PrdID").Value = prdID
                sqlcmd.Parameters("@SiteID").Value = siteID
                sqlcmd.Parameters("@SpecID").Value = specID
                reader = sqlcmd.ExecuteReader(System.Data.CommandBehavior.CloseConnection)
                dt.BeginLoadData()
                dt.Load(reader)
                dt.EndLoadData()
                If dt.Rows.Count > 0 Then
                    aRow = dt.Rows(0)
                End If
                Return aRow
            End Using
        End Function
    End Class
End Namespace
